﻿<%@ Page Title="Register" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Register.aspx.cs" Inherits="WebPages.Account.Register" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:CreateUserWizard ID="RegisterUser" runat="server" EnableViewState="false" OnCreatedUser="RegisterUser_CreatedUser">
        <LayoutTemplate>
            <asp:PlaceHolder ID="wizardStepPlaceholder" runat="server"></asp:PlaceHolder>
            <asp:PlaceHolder ID="navigationPlaceholder" runat="server"></asp:PlaceHolder>
        </LayoutTemplate>
        <WizardSteps>
            <asp:CreateUserWizardStep ID="RegisterUserWizardStep" runat="server">
                <ContentTemplate>
                    <h2>
                        Create a New Account
                    </h2>
                    <p>
                        Use the form below to create a new account.
                    </p>
                    <p>
                        Passwords are required to be a minimum of <%= Membership.MinRequiredPasswordLength %> characters in length.
                    </p>
                    <span class="failureNotification">
                        <asp:Literal ID="ErrorMessage" runat="server"></asp:Literal>
                    </span>
                    <asp:ValidationSummary ID="RegisterUserValidationSummary" runat="server" CssClass="failureNotification" 
                         ValidationGroup="RegisterUserValidationGroup"/>
                    <div class="accountInfo">
                        <fieldset class="register">
                            <legend>Account Information</legend>
                            <p>
                                <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
                                <asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>
                                <asp:RequiredFieldValidator ControlToValidate="UserName" CssClass="failureNotification" Display="Dynamic" 
                                     ErrorMessage="User name is required." ID="UserNameRequired" runat="server" 
                                     ToolTip="User name is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator id="BadUserName1" 
                                                     ControlToValidate="UserName"
                                                     ValidationExpression="^[^<^>^'^\x22^:^\x3f^=]*$"
                                                     CssClass="failureNotification"
                                                     ErrorMessage="User name cannot contain ?.':=<>&#34;"
                                                     ToolTip="Username is required." 
                                                     runat="server"
                                                     ValidationGroup="RegisterUserValidationGroup">*</asp:RegularExpressionValidator>
                                <asp:RegularExpressionValidator id="BadUserName2" 
                                                     ControlToValidate="UserName"
                                                     ValidationExpression="^[\s\S]{4,30}$"
                                                     CssClass="failureNotification"
                                                     ErrorMessage="User name must be between 4 and 30 character long."
                                                     ToolTip="Username is required." 
                                                     runat="server"
                                                     ValidationGroup="RegisterUserValidationGroup">*</asp:RegularExpressionValidator>

                            </p>
                            <p>
                                <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label>
                                <asp:TextBox ID="Email" runat="server" CssClass="textEntry"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email" 
                                     CssClass="failureNotification" ErrorMessage="E-mail is required." ToolTip="E-mail is required." 
                                     ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator id="BadEmail" 
                                                     ControlToValidate="Email"
                                                     ValidationExpression="^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-zA-Z0-9]{1}[a-zA-Z0-9\-]{0,62}[a-zA-Z0-9]{1})|[a-zA-Z])\.)+[a-zA-Z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$"
                                                     CssClass="failureNotification"
                                                     ErrorMessage="Bad e-mail address."
                                                     ToolTip="Bad e-mail." 
                                                     runat="server"
                                                     ValidationGroup="RegisterUserValidationGroup">*</asp:RegularExpressionValidator>                            
                            </p>
                            <p>
                                <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                                <asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
                                <asp:RegularExpressionValidator id="PasswordTooShort" 
                                                     ControlToValidate="Password"
                                                     ValidationExpression="^[\s\S]{6,50}$"
                                                     CssClass="failureNotification"
                                                     ErrorMessage="Password must be a minimum of 6 characters in length."
                                                     ToolTip="Password is too short." 
                                                     runat="server"
                                                     ValidationGroup="RegisterUserValidationGroup">*</asp:RegularExpressionValidator>

                                <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" 
                                     CssClass="failureNotification" ErrorMessage="Password is required." ToolTip="Password is required." 
                                     ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>

                            </p>
                            <p>
                                <asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label>
                                <asp:TextBox ID="ConfirmPassword" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
                                <asp:RequiredFieldValidator ControlToValidate="ConfirmPassword" CssClass="failureNotification" Display="Dynamic" 
                                     ErrorMessage="Confirm Password is required." ID="ConfirmPasswordRequired" runat="server" 
                                     ToolTip="Confirm Password is required." ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
                                <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword" 
                                     CssClass="failureNotification" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."
                                     ValidationGroup="RegisterUserValidationGroup">*</asp:CompareValidator>
                            </p>
                            <p>
                                <asp:Label ID="QuestionLabel" runat="server" AssociatedControlID="Question">Security Question:</asp:Label>
                                <asp:TextBox ID="Question" runat="server" CssClass="textEntry"></asp:TextBox>?
                                <asp:RequiredFieldValidator ID="QuestionRequired" runat="server" ControlToValidate="Question"
                                    CssClass="failureNotification" ErrorMessage="Security question is required." ToolTip="Security question is required."
                                    ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>
                            </p>
                            <p>
                                <asp:Label ID="AnswerLabel" runat="server" AssociatedControlID="Answer">Security Answer:</asp:Label>
                                <asp:TextBox ID="Answer" runat="server" CssClass="textEntry"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="AnswerRequired" runat="server" ControlToValidate="Answer"
                                    CssClass="failureNotification" ErrorMessage="Security answer is required." ToolTip="Security answer is required."
                                    ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>                            
                            </p>
                        </fieldset>
                        <p class="submitButton">
                            <asp:Button ID="CreateUserButton" runat="server" CommandName="MoveNext" Text="Create User" 
                                 ValidationGroup="RegisterUserValidationGroup"/>
                        </p>
                    </div>
                </ContentTemplate>
                <CustomNavigationTemplate>
                </CustomNavigationTemplate>
            </asp:CreateUserWizardStep>
            <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
                <ContentTemplate>
                    <div class="accountInfo">
                        <fieldset class="register">
                            <legend>Successfull registration</legend>
                            <p>
                                You have successfully created a new MyApp user account. To sign in, we need you to
                                first confirm your identity by visiting the link that was just e-mailed to you.
                            </p>
                            <p>
                                This little security check helps keep MyApp a community of real people using real identities.
                            </p>
                            <p>
                                <b>Thank you for registering!</b>
                            </p>
                        </fieldset>
                    </div>
                </ContentTemplate>
            </asp:CompleteWizardStep>
        </WizardSteps>
    </asp:CreateUserWizard>
</asp:Content>
